home *** CD-ROM | disk | FTP | other *** search
- unit ClientForm;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Corba, DrBob42_i, DrBob42_c, StdCtrls;
-
- type
- TForm1 = class(TForm)
- ButtonDeposit: TButton;
- LabelBalance: TLabel;
- ButtonWithdraw: TButton;
- procedure FormCreate(Sender: TObject);
- procedure ButtonDepositClick(Sender: TObject);
- procedure ButtonWithdrawClick(Sender: TObject);
- private
- { private declarations }
- Rate: Rates;
- Acct: Account;
- MyAcct: MyAccount;
- protected
- { protected declarations }
- procedure InitCorba;
- public
- { public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
- {$R *.DFM}
-
- procedure TForm1.InitCorba;
- begin
- CorbaInitialize;
- Rate := TRatesHelper.Bind;
- Acct := TAccountHelper.Bind;
- MyAcct := TMyAccountHelper.Bind;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- InitCorba;
- end;
-
- procedure TForm1.ButtonDepositClick(Sender: TObject);
- begin
- Assert(MyAcct <> nil,'No connection to CORBA Server');
- MyAcct.deposit(1);
- LabelBalance.Caption :=
- Format('Current balance: %f (%f%%)',
- [MyAcct.balance,MyAcct.get_rates(Rate)])
- end;
-
- procedure TForm1.ButtonWithdrawClick(Sender: TObject);
- begin
- Assert(MyAcct <> nil,'No connection to CORBA Server');
- try
- try
- MyAcct.withdraw(42);
- except
- on E: EAccountException do
- ShowMessage(Format(E.Error.ErrorMessage,[E.Error.Balance]))
- end
- finally
- LabelBalance.Caption :=
- Format('Current balance: %f (%f%%)',
- [MyAcct.balance,MyAcct.get_rates(Rate)])
- end;
- end;
-
- end.
-